package org.internna.expensetracker.model;

import java.util.Locale;

import org.internna.expensetracker.model.security.UserDetailsDataOnDemand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.roo.addon.dod.RooDataOnDemand;

@RooDataOnDemand(entity = Account.class)
public class AccountDataOnDemand {

	@Autowired
    private AccountTypeDataOnDemand accountTypeDataOnDemand;
    
    @Autowired
    private FinancialInstitutionDataOnDemand financialInstitutionDataOnDemand;
    
    @Autowired
    private UserDetailsDataOnDemand userDetailsDataOnDemand;

	public Account getNewTransientAccount(int index) {
        org.internna.expensetracker.model.Account obj = new org.internna.expensetracker.model.Account();
        obj.setName("name_" + index);
        obj.setDescription("description_" + index);
        obj.setFavorite(Boolean.TRUE);
        obj.setLastModified(new java.util.GregorianCalendar(java.util.Calendar.getInstance().get(java.util.Calendar.YEAR), java.util.Calendar.getInstance().get(java.util.Calendar.MONTH), java.util.Calendar.getInstance().get(java.util.Calendar.DAY_OF_MONTH), java.util.Calendar.getInstance().get(java.util.Calendar.HOUR_OF_DAY), java.util.Calendar.getInstance().get(java.util.Calendar.MINUTE), java.util.Calendar.getInstance().get(java.util.Calendar.SECOND) + new Double(Math.random() * 1000).intValue()).getTime());
        obj.setInitialBalance(new java.math.BigDecimal(index));
        obj.setClosed(Boolean.TRUE);
        obj.setOpened(new java.util.GregorianCalendar(java.util.Calendar.getInstance().get(java.util.Calendar.YEAR), java.util.Calendar.getInstance().get(java.util.Calendar.MONTH), java.util.Calendar.getInstance().get(java.util.Calendar.DAY_OF_MONTH), java.util.Calendar.getInstance().get(java.util.Calendar.HOUR_OF_DAY), java.util.Calendar.getInstance().get(java.util.Calendar.MINUTE), java.util.Calendar.getInstance().get(java.util.Calendar.SECOND) + new Double(Math.random() * 1000).intValue()).getTime());
        obj.setCreated(new java.util.GregorianCalendar(java.util.Calendar.getInstance().get(java.util.Calendar.YEAR), java.util.Calendar.getInstance().get(java.util.Calendar.MONTH), java.util.Calendar.getInstance().get(java.util.Calendar.DAY_OF_MONTH), java.util.Calendar.getInstance().get(java.util.Calendar.HOUR_OF_DAY), java.util.Calendar.getInstance().get(java.util.Calendar.MINUTE), java.util.Calendar.getInstance().get(java.util.Calendar.SECOND) + new Double(Math.random() * 1000).intValue()).getTime());
        obj.setAccountType(accountTypeDataOnDemand.getRandomAccountType());
        obj.setHeldAt(financialInstitutionDataOnDemand.getRandomFinancialInstitution());
        obj.setOwner(userDetailsDataOnDemand.getRandomUserDetails());
        obj.setLocale(null);
        return setExtraData(obj);
    }
	
	public Account setExtraData(Account account) {
		account.setLocale(Locale.GERMANY);
		return account;
	}

}
